package org.tech4j.springboot.starter.distributedlock.api.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.tech4j.springboot.starter.distributedlock.api.ILock;
import org.tech4j.springboot.starter.distributedlock.api.aop.DistributeLockAspect;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2023/2/19 22:39
 **/
@Configuration
public class DistributedLockConfiguration {

    @Bean
    @ConditionalOnBean(ILock.class)
    @ConditionalOnMissingBean
    public DistributeLockAspect distributeLockAspect(ILock lock) {
        return new DistributeLockAspect(lock);
    }
}
